/**
 * Created by 高磊 on 2017/2/13.
 */
(function (angular) {

    //主页面的路由器,导入路由器模块
    var app=angular.module("mainApp",["ngRoute","mainApp.in_theaters","mainApp.subject"]);
    app.config(["$routeProvider","$locationProvider",function ($routeProvider,$locationProvider) {
        //位置提供商的hash提前修正(据说是ang1.6版本后就得修正这个)
        $locationProvider.hashPrefix("");

        $routeProvider
            .when("/movie/:type/:page?",{
                //注入模板和控制器
                templateUrl:"js/module/in_theaters/template.html",
                controller:"in_theatersCtrl"
            })
            .when("/subject/:id",{
                templateUrl:"js/module/subject/template.html",
                controller:"subjectCtrl"
            })
            .otherwise({
                redirectTo:"/movie/in_theaters"
            })

    }])
    
    app.controller("searchCtrl",["$scope","$route",function ($scope,$route) {
        $scope.searchText="";
        $scope.search=function () {
            if($scope.searchText.length>0){
                console.log($scope.searchText);
                $route.updateParams({type:"search",q:$scope.searchText})
                $scope.searchText="";
            }
        }
    }])
})(angular)